/*
	login登录页面 
*/

/*
	点击图片(img)出现二维码
		思路：
			1.首先获取所有操作的节点对象(img)，并且隐藏
*/
window.onload = function(){
	
	/*
		登录页面 
	*/
	var login_click = document.getElementById("login_click");     //获取要点击的图片的节点对象
	var box1 = document.getElementById("box1")     //获取隐藏盒子（二维码div）的节点对象
	var login_cuo = document.getElementById("login_cuo");      //获取隐藏盒子的关闭按钮的节点对象
	
	//console.log(img);
	console.log(login_click);
	login_click.onclick = function(){               //二维码的点击事件
		box1.style.display = "block";                  //点击二维码时这个页面(box1)显示
		//alert("hello");
	}
	login_cuo.onclick = function(){           //添加一个点击事件使点击按钮是页面隐藏
		box1.style.display = "none";            //隐藏整个页面
	}
	
	
	var login_t1 = document.getElementById("login_t1")
	var login_t2 = document.getElementById("login_t2")
	var loginsp1 = document.getElementById("login_sp1")
	var loginsp2 = document.getElementById("login_sp2")
	var btn = document.getElementById("btn")
	var a = getCookie('username')
	var b = getCookie('password')
	var c = document.getElementsByTagName("input")[0];


/*
	function callback(data)
		{
			alert(data.tips);
		}
		
		$('button').click(function(){
			//$.get('05-test.php','username=xiaoming',callback,'json');
			$.post('http://www.xiangmusan.com/index/user/login','username=xiaoming',callback,'json');
		});
	*/

	login_t1.onblur = function(){
	

		
		if(login_t1.value != a){
			loginsp1.innerHTML = '该用户未注册'
			alert(d);
		}else{
			loginsp1.innerHTML = ''
			}
		}
	
	login_t2.onblur = function(){
		if(login_t2.value != b){
			loginsp2.innerHTML = '密码错误'
		}else{
			loginsp2.innerHTML = ''
		}
	}
	btn.onclick = function(){
		if(login_t1.value != '' && login_t2.value != '' && loginsp1.innerHTML =='' & loginsp2.innerHTML == ''){
			localStorage["isLogin"] = true;
			location.href = 'index.html'
		}else{
			alert('请输入正确格式')
		}
	}
}